#!node
const rollup = require("rollup");
const typescript = require("rollup-plugin-typescript");
const resolve = require("rollup-plugin-node-resolve");
const commonjs = require("rollup-plugin-commonjs");
const polyfill = require("../rollup-plugin-polyfill/dist/rollup-plugin-polyfill");
const inject = require("@rollup/plugin-inject");
const { resolve: path_resolve } = require("path");
const path = require("path");
// const input_path =
//   "C:\\yzq\\arangojs\\arangojs\\src\\main\\ets\\core\\index.ts";
// const output_path = "C:\\yzq\\arangojs\\arangojs\\src\\main\\ets\\dist";
const input_path = path.resolve(__dirname, "../source/core/index.ts");
const output_path = path.resolve(__dirname, "../dist/cli-result.js");
async function main() {
  const bundle = await rollup.rollup({
    input: input_path,
    external: ["events"],
    plugins: [
      typescript(),
      resolve(),
      polyfill(),
      inject({
        modules: {
          URL: [
            path_resolve(
              __dirname,
              "../rollup-plugin-polyfill/polyfills/dist/url.js"
            ),
            "URL",
          ],
          URLSearchParams: [
            path_resolve(
              __dirname,
              "../rollup-plugin-polyfill/polyfills/dist/url.js"
            ),
            "URLSearchParams",
          ],
        },
      }),
    ],
  });

  await bundle.write({
    file: output_path,
    format: "es",
  });
}

main();
